package com.example.demo.Repository;



import com.example.demo.Entity.Warehouse;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Optional;

@Repository
public interface WarehouseRepo extends JpaRepository<Warehouse, Long> {
    // 可以添加自定义查询方法，例如：
    List<Warehouse> findByNameContaining(String name);
    List<Warehouse> findByAddress(String address);
    Optional<Warehouse> findByName(String name);
    // 等等...



    // @Query("SELECT oplog FROM OperationLog oplog WHERE oplog.user = :user AND oplog.type = :type")
    @Query("SELECT w FROM Warehouse w WHERE w.name = : name")
    Optional<Warehouse> getByName(@Param("name") String name);
}